<!DOCTYPE html>
<html lang="en">


<body data-type="index">
    <div class="am-g tpl-g">
        <!-- 头部 -->
        <div th:include="common/header :: atmHead"></div>
        <!-- 风格切换 -->

        <!-- 侧边导航栏 -->
        <div th:include="common/left :: atmLeft"></div>
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">
                <div class="row  am-cf">
                    
                    <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">流水操作</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form id="flowForm" action="/flow/downLoadFLows" method="post" class="am-form tpl-form-line-form">

                                    <input type="hidden" id="fileType" name="fileType" value="1">

                                <div class="am-form-group">
                                        <label for="myCardsSelect" class="am-u-sm-3 am-form-label">银行卡 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <select id="myCardsSelect" name="cardId" data-am-selected="{searchBox: 1}" style="display: none;">
                                            </select>
                                            <button type="button" class="am-btn am-btn-default am-radius" onclick="loadFlows()">查询</button>
                                            <button type="button" class="am-btn am-btn-default am-radius" onclick="downLoad(1)">下载CSV格式</button>
                                            <button type="button" class="am-btn am-btn-default am-radius" onclick="downLoad(2)">下载Excel格式</button>
                                        </div>

                                    </div>

                                    
                                    <div class="am-form-group">
                                        <label for="password" class="am-u-sm-3 am-form-label">密码 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <input type="password" class="tpl-form-input" name="password" id="password" placeholder="请输入6位银行卡密码">
                                            <small></small>
                                        </div>
                                    </div>

                                </form>

                                <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"></div>
                                <div class="widget-function am-fr">
                                   
                                </div>
                            </div>
                            <div class="widget-body  widget-body-lg am-fr">

                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                    <thead>
                                        <tr>
                                            <th>卡号</th>
                                            <th>金额</th>
                                            <th>备注</th>
                                            <th>时间</th>
                                        </tr>
                                    </thead>
                                    <tbody id="flowsDIV">
                                        <!-- more data -->
                                    </tbody>
                                </table>

                                <ul class="am-pagination">
                                  <li><a href="###" onclick="firstPage()">首页 &raquo;</a></li>
								  <li><a href="###" onclick="pre()">&laquo; 上一页</a></li>
								  <li><a href="###" onclick="next()">下一页 &raquo;</a></li>
								  <li><a href="###" onclick="lastPage()">尾页 &raquo;</a></li>
								  								<li id="pageInfoDIV">1/1</li>
								</ul>
                            </div>
                        </div>
                            </div>

                        </div>
                    </div>
                </div>


                    
                </div>

                </div>



            </div>
        </div>
    </div>
    </div>


    <script>
        $('#flowA').addClass('active')

        function downLoad(fileTypeValue) {
            $('#fileType').val(fileTypeValue);
            $('#flowForm').submit();
        }

        //默认当前页为1
        var currentPage = 1;
        //默认总页数
        var totalPage = 1;
        
        function next() {
            if (currentPage == totalPage) {
                return;
            }
            ++currentPage
            loadFlows();
        }

        function pre() {
            if (currentPage == 1) {
                return;
            }
            --currentPage
            loadFlows();
        }

        function firstPage() {
            currentPage = 1;
            loadFlows();
        }

        function lastPage() {
            currentPage = totalPage;
            loadFlows();
        }

        function loadFlows() {
            if ($('#password').val() == '') {
                alert('请输入密码');
                return;
            }

            if ($('#myCardsSelect').val() == 'no') {
                alert('请选择银行卡');
                return;
            }

            atm.ajax({
                requestType : 'POST',
                requestURL : '/card/queryFlow',
                requestParam : {
                    cardId : $('#myCardsSelect').val(),
                    pwd : $('#password').val(),
                    currentPage : currentPage
                },
                successCallBackFunction : function (result) {
                    var flowsHtml = '';
                    var flows = result.data.pageData;
                    totalPage = result.data.totalPage;

                    for (var i=0; i<flows.length; i ++) {
                        var flow = flows[i];

                        flowsHtml += '<tr class="gradeX">\n' +
                            '                                            <td>'+flow.cardNum+'</td>\n' +
                            '                                            <td>'+flow.amount+'</td>\n' +
                            '                                            <td>'+flow.remark+'</td>\n' +
                            '                                            <td>'+flow.createTime+'</td>\n' +
                            '                                        </tr>';
                    }

                    $('#flowsDIV').html(flowsHtml);
                    $('#pageInfoDIV').html(currentPage + '/' + totalPage);
                }
            })
        }

        //加载银行卡
        atm.loadMyCard();
    </script>

</body>

</html>